package main

import (
	"encoding/json"
	"fmt"
)

// 对切片进行序列化
func testSlice() {
	
	var slice []map[string]interface{}
	var m1 map[string]interface{}
	var m2 map[string]interface{}
	// 使用map前，需要先make
	m1 = make(map[string]interface{})
	m1["name"] = "jack"
	slice = append(slice, m1)

	m2 = make(map[string]interface{})
	m2["name"] = "john"
	slice = append(slice, m2)

	data, err := json.Marshal(&slice)
	if err != nil {
		fmt.Println("err:", err)
		return
	}

	fmt.Printf("slice序列化后：%v\n", string(data))
}

func main() {

	testSlice()

}